package org.pz.expression;

import com.googlecode.aviator.AviatorEvaluator;
import com.googlecode.aviator.Expression;

import java.util.HashMap;
import java.util.Map;

public class ExpressionUtils {

    public static Object expressionExecute(String expression, Map<String, Object> map){
        Expression exp = AviatorEvaluator.compile(expression);
        return exp.execute(map);
    }

    public static void main(String[] args) {
        String expression = "(a > 5 && a < 9)";
        Map<String, Object> map = new HashMap<>();
        map.put("a", 8);
        map.put("b", 8);
        System.out.println( expressionExecute( expression, map) );
    }

}
